#!/bin/bash
rm -f *.tar.gz

buildtp=
if [ $# -gt 0 ]; then
	buildtp=$1
fi

if [ "$buildtp" = "linux" ] || [ -z "$buildtp" ]; then
	echo "build linux_amd64"
	GOOS=linux GOARCH=amd64 make
	cd build && tar czf lampmgr_linux_x64.tar.gz * && mv *.tar.gz ../ && cd .. && make clean
fi

if [ "$buildtp" = "windows" ] || [ -z "$buildtp" ]; then
	echo "build win64"
	GOOS=windows GOARCH=amd64 make
	mv build/bin/lampmanager build/bin/lampmanager.exe
	cd build && tar czf lampmgr_windows_x64.tar.gz * && mv *.tar.gz ../ && cd .. && make clean
fi

if [ "$buildtp" = "arm" ] || [ -z "$buildtp" ]; then
	echo "build linux_arm"
	GOOS=linux GOARCH=arm make
	cd build && tar czf lampmgr_arm.tar.gz * && mv *.tar.gz ../ && cd .. && make clean
fi
